package com.jrx.anytxn.transaction.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.transaction.bean.LoanParamBean;
import com.jrx.anytxn.transaction.bean.LoanPlanParamBean;
import com.jrx.anytxn.transaction.dto.common.CommonAddReq;
import com.jrx.anytxn.transaction.dto.loan.CustomerRenewalRes;
import com.jrx.anytxn.transaction.dto.loan.LoanReq;
import com.jrx.anytxn.transaction.entity.AmLoanMainInfo;
import com.jrx.anytxn.transaction.entity.AmRepaymentPlanInfo;
import com.jrx.anytxn.transaction.entity.AmWaiveRepaymentPlanInfo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 还款计划service
 *
 * @author : zhenghaopu
 * 2019/10/21
 */
public interface IRepaymentPlanService {

    /**
     * 根据订单id及状态查询客户银行贷款的还款计划信息
     * 禁止controller使用
     *
     * @param loanId 贷款id
     * @param customerId 客户id
     * @param tenantId 租户id
     * @param statusList 状态list
     * @return 还款计划list
     */
    List<AmRepaymentPlanInfo> getPlanList(String loanId, String customerId, String tenantId,
                                                  List<String> statusList) throws TxnBizException;

    /**
     * 构建还款计划入参
     *
     * @param amLoanMainInfo 贷款信息
     * @param businessDate 业务日期
     * @param loanAmt 贷款金额
     * @param tenor 期数
     ** @param loanParamBean 贷款参数
     * @return 还款计划入参
     */
    LoanPlanParamBean buildLoanPlanParamBean(AmLoanMainInfo amLoanMainInfo, Date businessDate,
                                             BigDecimal loanAmt, Integer tenor, LoanParamBean loanParamBean,Date firstPaymentDay) throws TxnBizException;

    /**
     * 构建还款计划入参(贷款试算)
     *
     * @param loanReq 试算请求
     * @param loanParamBean 贷款参数 bean
     * @return 还款计划入参
     */
    LoanPlanParamBean buildTrailLoanPlanParamBean(LoanReq loanReq, LoanParamBean loanParamBean) throws TxnBizException;

    /**
     * 还款计划生成
     * @param loanPlanParamBean
     * @return
     * @throws TxnBizException
     */
    List<AmRepaymentPlanInfo> buildRepaymentList(LoanPlanParamBean loanPlanParamBean) throws TxnBizException;



    /**
     * 产品贴息构建贴息还款计划
     * @param amRepaymentPlanInfoList
     * @param loanPlanParamBean
     * @return
     */
    List<AmWaiveRepaymentPlanInfo> buildWaiveRepaymentListByProduct(List<AmRepaymentPlanInfo> amRepaymentPlanInfoList, LoanPlanParamBean loanPlanParamBean) throws TxnBizException;



    /**
     * 计算首期还款日
     * @param loanDate
     * @param cycleDay
     * @param limitDay
     * @return
     */
    Date computeFirstPaymentDate(Date loanDate, Integer cycleDay, Integer limitDay);

    /**
     * 权益贴息/促销活动贴息 构建贴息还款计划
     * @param amRepaymentPlanInfoList
     * @param loanPlanParamBean
     * @return
     */
    List<AmWaiveRepaymentPlanInfo> buildWaiveRepaymentListByCustRightOrPromotion(List<AmRepaymentPlanInfo> amRepaymentPlanInfoList, LoanPlanParamBean loanPlanParamBean) throws TxnBizException;

    /**
     * 获取所有非取消状态还款计划
     * @param loanId
     * @param customerId
     * @param tenantId
     * @return
     * @throws TxnBizException
     */
    List<AmRepaymentPlanInfo> getPlanList(String loanId, String customerId, String tenantId) throws TxnBizException;

    /**
     * 客户续期信息查询
     * @param req
     * @return
     * @throws Exception
     */
    CustomerRenewalRes customerRenewalInfo(CommonAddReq req) throws Exception;

}
